import {
  axios
} from '@/utils/request'
/**
 * 车辆模块api
*/

// 新增
function addVehicle (data) {
  return axios({
    url: '/vehicle-service/vehicle',
    method: 'post',
    data
  })
}

// 编辑
function editVehicle (data) {
  return axios({
    url: '/vehicle-service/vehicle',
    method: 'put',
    data
  })
}

// 删除
function deleteVehicle (data) {
  return axios({
    url: '/vehicle-service/vehicle',
    method: 'delete',
    data
  })
}
// 停用 删除 恢复
function operateVehicle (data) {
  return axios({
    url: '/vehicle-service/vehicle/operateVehicle',
    method: 'put',
    data
  })
}
// 获取分页数据
function getVehiclePageData (query) {
  return axios({
    url: '/vehicle-service/vehicle/list',
    method: 'get',
    params: query
  })
}

// 获取某车辆零件信息
function getVehiclePartData (query) {
  return axios({
    url: '/vehicle-service/vehicle/ecu/list',
    method: 'get',
    params: query
  })
}

// 根据VIN、ecuModuleId查询车辆ECU当前版本
function getEcuVersion (query) {
  return axios({
    url: '/vehicle-service/vehicle/ecu/version',
    method: 'get',
    params: query
  })
}

// 车辆按品牌分组统计
function getVehicleBrandReport (query) {
  return axios({
    url: '/web-service/vehicle/report/countByBrand',
    method: 'get',
    params: query
  })
}

// 车辆按车型分组统计
function getVehicleModelReport (query) {
  return axios({
    url: '/web-service/vehicle/report/countByModel',
    method: 'get',
    params: query
  })
}

// 获娶某车辆ECU信息查询-时间线
function getVehicleEcuTimeline (query) {
  return axios({
    url: '/task-service/task/vehicle/ecu/list/timeline',
    method: 'get',
    params: query
  })
}

// 下载车辆导入模板文件
function downloadVehicleExcelTpl () {
  return axios({
    url: '/vehicle-service/vehicle/template/excel',
    method: 'get',
    responseType: 'blob'
  })
}

// 导入车辆文件
function uploadVehicleExcel (data) {
  return axios({
    url: '/vehicle-service/import/vehicle',
    method: 'post',
    data: data,
    timeout: 120000
  })
}
// 导入ECU车辆VIN
function uploadEcuVehicleVinExcel (data) {
  return axios({
    url: '/vehicle-service/import/ecu/vehicle',
    method: 'post',
    data: data
  })
}
// 查询车辆数
function getCarCount (params) {
  return axios({
    url: '/vehicle-service/vehicle/list/count',
    method: 'get',
    params
  })
}

// 获取车辆详情信息
function getVehicleInfo (params) {
  return axios({
    url: '/vehicle-service/vehicle/info',
    method: 'get',
    params
  })
}

// 解绑iccid
function unbindIccId (data) {
  return axios({
    url: '/vehicle-service/vehicle/unbindIccId',
    method: 'put',
    data
  })
}

// 获取车辆app应用
function getVehicleAppList (params) {
  return axios({
    url: '/vehicle-service/vehicle/app/list',
    method: 'get',
    params
  })
}

// 获娶某车辆SOTA升级信息-时间线
function getVehicleAppTimeline (query) {
  return axios({
    url: '/task-service/task/vehicle/app/list/timeline',
    method: 'get',
    params: query
  })
}

// 获取车辆配置数据
function getVehicleConfigData (query) {
  return axios({
    url: '/service-sale/vehicleConfig/config',
    method: 'get',
    params: query
  })
}

// 下载车辆配置文件
function downVehicleConfigFile (query) {
  return axios({
    url: '/service-sale/vehicleConfig/download/config',
    method: 'get',
    params: query,
    responseType: 'blob'
  })
}

// 占用
function getVehicleLockInfo (query) {
  return axios({
    url: '/vehicle-service/vehicle/lock/info',
    method: 'get',
    params: query
  })
}

// 获取某车辆的某ECU安装情况
function setVehiclePartInstallStatus (data) {
  return axios({
    url: '/vehicle-service/vehicle/ecu/retrofitted',
    method: 'put',
    data
  })
}

// 车辆导出
function exportVehicleList (params) {
  return axios({
    url: '/vehicle-service/vehicle/export',
    method: 'get',
    params: params,
    responseType: 'blob'
  })
}
// 导出车辆信息列表
function exportVehicleInfoList (params) {
  return axios({
    url: '/vehicle-service/vehicle/exportVehicles',
    method: 'get',
    params,
    responseType: 'blob'
  })
}
// 同步云服务证书数据
function syncCloudCertVin (data) {
  return axios({
    url: '/vehicle-service/vehicle/syncCloudCertVin',
    method: 'post',
    data: data,
    timeout: 120000
  })
}

// 解绑ICCID
function untieICCID (data) {
  return axios({
    url: '/vehicle-service/vehicle/unbindIccId',
    method: 'put',
    data
  })
}

// 版本历史同步查询
function getCarEcuHistory (data) {
  return axios({
    url: '/vehicle-service/vehicle/getCarEcuHistory',
    method: 'post',
    data
  })
}
// 具体车辆ecu升级历史查询
function getCarEcuUpgradeHistory (data) {
  return axios({
    url: '/vehicle-service/vehicle/getCarEcuUpgradeHistory',
    method: 'post',
    data
  })
}
// 车辆版本具体ecu版本查询
function getEcuVersionListByVehicleVersion (data) {
  return axios({
    url: '/vehicle-service/vehicle/getEcuVersionListByVehicleVersion',
    method: 'post',
    data
  })
}
// 车辆版本历史查询
function getVehicleVersionHistory (data) {
  return axios({
    url: '/vehicle-service/vehicle/getVehicleVersionHistory',
    method: 'post',
    data
  })
}
// 车辆版本具体ecu版本导出
function exportVehicleVersionSpecificEcuVersion (query) {
  return axios({
    url: '/vehicle-service/vehicle/export',
    method: 'get',
    params: query,
    responseType: 'blob'
  })
}

// 校验IccId
function checkIccId (params) {
  return axios({
    url: '/vehicle-service/vehicle/checkIccId',
    method: 'get',
    params
  })
}

export default {
  addVehicle:addVehicle,
  editVehicle:editVehicle,
  getVehiclePageData:getVehiclePageData,
  exportVehicleList:exportVehicleList,
  getVehiclePartData,
  getVehicleBrandReport,
  getVehicleModelReport,
  getVehicleEcuTimeline,
  downloadVehicleExcelTpl,
  uploadVehicleExcel:uploadVehicleExcel,
  getCarCount,
  getVehicleInfo:getVehicleInfo,
  unbindIccId:unbindIccId,
  checkIccId:checkIccId,
  getVehicleAppList,
  getVehicleAppTimeline,
  deleteVehicle:deleteVehicle,
  getVehicleConfigData,
  downVehicleConfigFile,
  getVehicleLockInfo,
  setVehiclePartInstallStatus :setVehiclePartInstallStatus,
  uploadEcuVehicleVinExcel :uploadEcuVehicleVinExcel,
  syncCloudCertVin,
  exportVehicleInfoList,
  untieICCID,
  operateVehicle,
  getCarEcuHistory,
  getCarEcuUpgradeHistory,
  getEcuVersionListByVehicleVersion,
  getVehicleVersionHistory,
  exportVehicleVersionSpecificEcuVersion,
  getEcuVersion
}
